package com.csizg.facerecognition;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

/**
 * 主界面
 *
 * @author haohao(ronghao3508@gmail.com) on 2018/5/8 10:26
 * @version v1.0
 */
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        checkPermission();
    }

    public void onClick1(View view) {
        Intent intent = new Intent(MainActivity.this, FdHActivity.class);
        startActivity(intent);
    }

    public void onClick2(View view) {
        Intent intent = new Intent(MainActivity.this, FdVActivity.class);
        startActivity(intent);
    }

    public void onClick3(View view) {
        Intent intent = new Intent(MainActivity.this, FdVRActivity.class);
        startActivity(intent);
    }

    public void onClick4(View view) {
        Intent intent = new Intent(MainActivity.this, FdVR1Activity.class);
        startActivity(intent);
    }

    public void onClick40(View view) {
        Intent intent = new Intent(MainActivity.this, FdVR1sActivity.class);
        startActivity(intent);
    }

    public void onClick41(View view) {
        Intent intent = new Intent(MainActivity.this, FdVR1NDActivity.class);
        startActivity(intent);
    }

    public void onClick5(View view) {
        MyDialog dialog = new MyDialog(this);
        Window dialogWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = 900; // 宽度
        lp.height = 1200; // 高度
        dialogWindow.setAttributes(lp);
        dialog.show();
    }

    private void checkPermission(){
        if(Build.VERSION.SDK_INT < 23) return;

        boolean noCamera = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)!= PackageManager.PERMISSION_GRANTED;
        if(noCamera){
            String[] permissions = new String[]{Manifest.permission.CAMERA};
            ActivityCompat.requestPermissions(this,permissions,0);
        }
    }
}
